import com.adobe.cairngorm.control.CairngormEventDispatcher;

import mx.collections.ArrayCollection;

import net.optix.ip.events.UpdateFirmsEvent;
import net.optix.ip.model.ModelLocator;
[Bindable]
private var model:ModelLocator	=	ModelLocator.getInstance();


[Bindable]
private var firmsInvention:ArrayCollection;

private var _firms:ArrayCollection;

public function set firms(value:ArrayCollection):void
{
	_firms	=	value;
	
	firmsInvention	=	new ArrayCollection();
	
	for(var i:int=0; i<value.length; i++)
	{
		if(value[i].bAuction == 1)
		{
			firmsInvention.addItem(value[i]);
		}
	}
}

public function get firms():ArrayCollection
{
	return _firms;
}

private function save():void
{
	var firmsString:String	=	"";
	try
	{
		for(var i:int=0; i<firmsInvention.length-1; i++)
		{
			firmsString	+=	firmsInvention[i].firmID+",";
		}
		firmsString	+=	firmsInvention[i].firmID;
	}
	catch(error:Error){}
	
	
	var updateFirms:UpdateFirmsEvent	=	new UpdateFirmsEvent(firmsString,0);
	com.adobe.cairngorm.control.CairngormEventDispatcher.getInstance().dispatchEvent(updateFirms);
}

private function deleteFirm():void
{
	firmsInvention.removeItemAt(firmsInvention.getItemIndex(mydata.selectedItem));
}